﻿using System;
using System.Windows.Forms;

namespace TextEditor
{
    

    public class A_Undo : A_Action
    {
        public A_Undo()
        {
            base.HotKey = Keys.Control | Keys.Z;
        }

        public override string ActionName()
        {
            return "undo";
        }

        public override bool Execute()
        {
            base.myOwnerDocument._Undo();
            return true;
        }

        public override string GetText()
        {
            if (this.isEnable())
            {
                A_Action action = (A_Action) base.myOwnerDocument.UndoList[base.myOwnerDocument.UndoList.Count - 1];
                return ("撤销 " + action.UndoName());
            }
            return "无可撤销的操作";
        }

        public override bool isEnable()
        {
            return ((base.myOwnerDocument.CanModify() && (base.myOwnerDocument.UndoList.Count > 0)) && base.isEnable());
        }
    }
}

